﻿package com.designoutput.ui.controls
{
    import com.designoutput.icon.UI;
    
    import flash.display.*;
    import flash.events.*;

    public class IconButton extends Sprite
    {
        private var over:Bitmap;
        private var out:Bitmap;

        public function IconButton(outbd:BitmapData,overbd:BitmapData=null)
        {
			this.out = new Bitmap(outbd);
            this.over = new Bitmap(overbd==null?outbd.clone():overbd);
            UI.Desaturate(this.out.bitmapData);
            this.over.visible = false;
            addChild(this.out);
            addChild(this.over);
            this.addEventListener(MouseEvent.MOUSE_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.MouseOut, false, 0, true);
        }

        private function MouseOut(event:MouseEvent) : void
        {
            this.out.visible = true;
            this.over.visible = false;
        }

        private function MouseOver(event:MouseEvent) : void
        {
            this.out.visible = false;
            this.over.visible = true;
        }

    }
}
